package com.tansun.easycare.rule.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.tansun.easycare.core.service.impl.BaseServiceImpl;

public class RuleInterceptor extends BaseServiceImpl implements HandlerInterceptor{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
//		try {
//			if(StringUtils.isEmpty(UserUtils.getUser().getLoginName())) {
//				String userName = "administrator";
//				if(!StringUtils.isEmpty(request.getParameter("user")))
//					userName = request.getParameter("user");
//				UsernamePasswordToken shiroToken = 
//						new UsernamePasswordToken(userName, null, false, null, null, false);
//				UserUtils.getSubject().login(shiroToken);
//			}
//		} catch (AuthenticationException e) {
//			e.printStackTrace();
//		}
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		// TODO Auto-generated method stub
		
	}

}
